package storage

import (
    "time"
    "github.com/yangyongzhen/mqtt-broker/internal/protocol/common"
)

// 存储接口
type Store interface {
    // 会话管理
    SaveSession(clientID string, session *Session) error
    LoadSession(clientID string) (*Session, error)
    DeleteSession(clientID string) error
    
    // 消息存储
    SaveMessage(clientID string, message *common.Message) error
    LoadMessages(clientID string) ([]*common.Message, error)
    DeleteMessage(clientID string, packetID uint16) error
    
    // 保留消息
    SaveRetainedMessage(topic string, message *common.Message) error
    LoadRetainedMessage(topic string) (*common.Message, error)
    DeleteRetainedMessage(topic string) error
    
    // 订阅管理
    SaveSubscription(clientID string, subscription *common.Subscription) error
    LoadSubscriptions(clientID string) ([]*common.Subscription, error)
    DeleteSubscription(clientID string, topic string) error
}

// 会话信息
type Session struct {
    ClientID      string
    CleanSession  bool
    Subscriptions map[string]*common.Subscription
    PendingAcks   map[uint16]*common.Message
    LastSeen      time.Time
}
